//
//  CategoryCell.m
//  YunGou
//
//  Created by macbook on 16/5/16.
//  Copyright © 2016年 macbook. All rights reserved.
//

#import "CategoryCell.h"
#import "YGProgressBarView.h"
#import <UIImageView+WebCache.h>

@interface CategoryCell ()
@property (weak, nonatomic) IBOutlet UIImageView *thumbImage;
@property (weak, nonatomic) IBOutlet UILabel *titLabel;
@property (weak, nonatomic) IBOutlet UILabel *totalNeedLabel;
@property (weak, nonatomic) IBOutlet UILabel *surplusLabel;
@property (weak, nonatomic) IBOutlet YGProgressBarView *progressView;
@end

@implementation CategoryCell

- (void)awakeFromNib {
        // Initialization code
}

- (void)setProductModel:(ProductModel *)productModel{
    _productModel = productModel;
    [_thumbImage sd_setImageWithURL:[NSURL URLWithString:[ImageUrl stringByAppendingString:productModel.thumb]]];
    _titLabel.text = productModel.title;
    _totalNeedLabel.text = [NSString stringWithFormat:@"%ld", productModel.zongrenshu];
    _surplusLabel.text = [NSString stringWithFormat:@"%ld",productModel.zongrenshu - productModel.canyurenshu];
    _progressView.progress = productModel.canyurenshu/productModel.zongrenshu;

}

- (IBAction)addToShopCartClicked:(UIButton *)sender {
    if (self.block) {
        self.block();
    }
}

@end
